/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ineatconseil.yougo.wicket.ui.admin.panel;

import com.ineatconseil.yougo.dto.UserDto;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.validation.validator.EmailAddressValidator;
import org.apache.wicket.validation.validator.StringValidator.MaximumLengthValidator;

/**
 *
 * @author nicolasger
 */
public class AddUser extends Panel {

	public AddUser(String id) {
		super(id);
		setOutputMarkupId(true);
		add(new UserForm("userForm", new UserDto()));
	}

	public class UserForm extends Form<UserDto> {

		public UserForm(String id, UserDto user) {
			super(id);
			setModel(new CompoundPropertyModel(user));
			add(new TextField("prenom").setRequired(true));
			add(new TextField("nom").setRequired(true).add(
					new MaximumLengthValidator(10)));
			add(new TextField("email").add(EmailAddressValidator.getInstance()));
			add(new CheckBox("actif"));
			add(new CheckBox("admin"));
			add(new FeedbackPanel("feedback"));
		}
	}
}
